package de.mhu.mandalaui.table;

import java.util.LinkedList;
import java.util.List;

import de.mhu.mandalaui.Response;

public class StaticTable extends AbstractTable {

	private LinkedList<TableRow> rows = new LinkedList<TableRow>();
	
	@Override
	protected void doInitialize() {
	}

	@Override
	protected void doDestroy() {
	}

	public List<TableRow> getRows() {
		return rows;
	}
	
	@Override
	public void render(Response response) {
		response.startTag("table", "table", this);
		if (getHeader() != null) {
			response.startTag("thead", null, null);
			response.containerEnter(getHeader());
			getHeader().render(response);
			response.containerLeave();
			response.endTag("thead");
		}
		
		for (TableRow row : rows) {
			response.containerEnter(row);
			row.render(response);
			response.containerLeave();
		}
		
		response.endTag("table");
	}

}
